<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<style type="text/css">
.table_1 {
    border: 1px #95a7bf;
    border-collapse: collapse;
}
.table_1 td {
	font-family: "宋体", "Verdana", "Arial", "Helvetica", "sans-serif";
	font-size: 12px;
	color: #000000;
        //background-color: #FFF9F4;
        border: 1px solid #95a7bf;
        border-collapse: collapse;
}

</style>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.js"></script>
<script type="text/javascript">
var path = "<%=request.getContextPath()%>";
var scrollTop = 1000;
function dosubmit(){
	var submitUrl = path+"/chat!insert";
	var nickname = $("#nickname").val();
	var tale = $("#tale").val();
	jQuery.ajax({
		data : {"dto.nickname":nickname,"dto.tale":tale},
		type : "post",
		url : submitUrl,
		success : function(data){
			$("#chatTop").contents().find("#taleWin").append("<tr><td align='right'>"+nickname+":</td><td>"+tale+"</td></tr>");
			$("#tale").val("");
			scrollTop = scrollTop + 100;
			$("#chatTop").contents().scrollTop(scrollTop);
		}
	});
}

function dosubmit2(){
	var submitUrl = path+"/chat!select";
	jQuery.ajax({
		type : "post",
		url : submitUrl,
		dataType : "json",
		success : function(json){
			$(json).each(function(){
				$("#chatTop").contents().find("#taleWin").append("<tr><td align='right'>"+this.nickname+":</td><td>"+this.uuid+" || "+this.tale+"</td></tr>");
				scrollTop = scrollTop + 20;
				$("#chatTop").contents().scrollTop(scrollTop);
			});
			window.setTimeout(dosubmit2, 1000);
		}
	});
}
</script>
</head>
<body onload="dosubmit2()">
聊天无罪,灌水有理.
<hr>
<iframe height="500" width="700" id="chatTop" name="chatTop" src="<%=request.getContextPath()%>/chatTop.jsp"></iframe>
<hr>
<table >
<tr><td>欢迎您:<%=request.getAttribute("name") %></td></tr>
<tr><td><input id="nickname" value="<%=request.getAttribute("name") %>" type="hidden"/></td></tr>
<tr><td><input id="tale" value="要说的话" type="text"/></td></tr>
<tr><td><input value="提交" type="submit" onclick="dosubmit()"/></td></tr>
</table>
</body>
</html>